package com.itheima.demo;

/**
 * @author jiangxun
 * @date 11-20-2024
 */
public class SmartHomeControl {
    /**
     * 多态
     */
    public void control(ElectricAppliance appliances) {
        System.out.println(appliances.getName() + "状态目前是：" + (appliances.isStatus() ? "打开" : "关闭"));
        System.out.println("开始您的操作");
        appliances.press();
        System.out.println(appliances.getName() + "状态目前是：" + (appliances.isStatus()? "打开" : "关闭"));
    }

    public void printAllStatus(ElectricAppliance[] appliances){
        for (int i = 0; i < appliances.length; i++) {
            System.out.println(appliances[i].getName() + "状态目前是：" + (appliances[i].isStatus()? "打开" : "关闭"));
        }
    }
}
